package designpattern.singleton;

import java.util.HashMap;
import java.util.Map;

/**
 * 数据库连接创建工厂
 */
public class DBFactory {
    private static Connection connection;
    private static Map<String,Connection> register=new HashMap<>();

    public static Connection getConnection(String type){
        if(connection==null){
            connection=register.get(type);
        }
        return connection;
    }

    public static void add(String type,Connection connection){
        register.put(type,connection);
    }
}
